# -*- encoding:utf-8 -*-
# @time:2022-11-07 21:50
# @Author : serein
# @Email: serein@qq.com
# @File:urls.py
# @Software: PyCharm

from .views import StudentViewSet,TeacherViewSet,ClassesViewSet
from django.urls import path
from rest_framework.routers import DefaultRouter
#如果路由不同就要重新写个path
urlpatterns = [
    # path('students/',StudentViewSet.as_view({'get':'list' , 'post':'create'})),
    # path('students/<pk>/',StudentViewSet.as_view({'get':'retrieve','put':'update',"delete":"destroy"})),
    # path('teachers/',TeacherViewSet.as_view({'get':'list' , 'post':'create'})),
    # path('teachers/<pk>/',TeacherViewSet.as_view({'get':'retrieve','put':'update',"delete":"destroy"}))
]
#路由器的简写是建立在视图使用view.model上面的
router = DefaultRouter()#创建路由器
router.register('teachers',TeacherViewSet)#注册路由器
router.register('classes',ClassesViewSet)
router.register('students',StudentViewSet)
urlpatterns += router.urls#拼接路由器
